home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1993 September / 1993-09.d64 / vector finder.pp (.txt) < prev   
Commodore BASIC  |  2022-09-20  |  668b  |  28 lines

  1. 90 print"[147]":poke53280,6:poke53281,6
  2. 100 rem vector finder
  3. 105 dim m(3),a(3):q$="y"
  4. 110 x=0:y=0
  5. 120 def fn r(x)=(int(x*1000+.5))/1000
  6. 130 for i=1 to 2
  7. 140 print
  8. 150 print "magnitude of vector";i;
  9. 160 input m(i)
  10. 170 print "angle of vector";i;
  11. 180 input a(i)
  12. 190 a(i)=a(i)*(NULL)/180
  13. 200 y=m(i)*sin(a(i))+y
  14. 210 x=m(i)*cos(a(i))+x
  15. 220 next i
  16. 230 m(3)=fn r(sqr(x*x+y*y))
  17. 240 a(3)=fn r((atn(y/x))*180/(NULL))
  18. 250 if x<0 then a(3)=a(3)+180
  19. 260 if a(3)<0 then a(3)=a(3)+360
  20. 270 if m(3)=0 then a(3)=0
  21. 280 print
  22. 290 print "magnitude of resultant vector =";m(3)
  23. 300 print "angle of resultant vector =";a(3)
  24. 310 print
  25. 320 print "figure another";
  26. 330 input q$
  27. 340 if q$="y" then 110
  28.